﻿using System.Threading.Tasks;
using ff14bot;
using ff14bot.AClasses;
using ff14bot.Enums;
using TreeSharp;
using Action = TreeSharp.Action;
using ff14bot.Objects;
using ff14bot.Managers;
using ff14bot.Helpers;
using System.Windows.Media;
using MoreDots.SpellNames.Jobs;
using MoreDots.SpellNames.Classes;
using Buddy.Coroutines;
using MoreDots.SpellNames;
using System;
using System.Diagnostics;
using System.Threading;

namespace MoreDots
{
    public abstract class MoreDots : CombatRoutine
    {
        #region CombatRoutine Overrides

        public override float PullRange { get { return 25; } }

        public async override void Pulse() { await OutOfCombat(); }
        public override void Initialize() { }
        public override bool WantButton { get { return false; } }

        #endregion

        #region Combat

        public override Composite CombatBehavior
        {
            get
            {
                switch ((int)Core.Player.ClassLevel)
                {
                    case 50:
                        return new ActionRunCoroutine(ctx => CombatLvL50());
                    case 49:
                    case 48:
                        return new ActionRunCoroutine(ctx => CombatLvL48());
                    case 47:
                    case 46:
                        return new ActionRunCoroutine(ctx => CombatLvL46());
                    case 45:
                    case 44:
                        return new ActionRunCoroutine(ctx => CombatLvL44());
                    case 43:
                    case 42:
                        return new ActionRunCoroutine(ctx => CombatLvL42());
                    case 41:
                    case 40:
                        return new ActionRunCoroutine(ctx => CombatLvL40());
                    case 39:
                    case 38:
                        return new ActionRunCoroutine(ctx => CombatLvL38());
                    case 37:
                    case 36:
                        return new ActionRunCoroutine(ctx => CombatLvL36());
                    case 35:
                    case 34:
                        return new ActionRunCoroutine(ctx => CombatLvL34());
                    case 33:
                    case 32:
                        return new ActionRunCoroutine(ctx => CombatLvL32());
                    case 31:
                    case 30:
                        return new ActionRunCoroutine(ctx => CombatLvL30());
                    case 29:
                    case 28:
                        return new ActionRunCoroutine(ctx => CombatLvL28());
                    case 27:
                    case 26:
                        return new ActionRunCoroutine(ctx => CombatLvL26());
                    case 25:
                    case 24:
                        return new ActionRunCoroutine(ctx => CombatLvL24());
                    case 23:
                    case 22:
                        return new ActionRunCoroutine(ctx => CombatLvL22());
                    case 21:
                    case 20:
                        return new ActionRunCoroutine(ctx => CombatLvL20());
                    case 19:
                    case 18:
                        return new ActionRunCoroutine(ctx => CombatLvL18());
                    case 17:
                    case 16:
                        return new ActionRunCoroutine(ctx => CombatLvL16());
                    case 15:
                    case 14:
                        return new ActionRunCoroutine(ctx => CombatLvL14());
                    case 13:
                    case 12:
                        return new ActionRunCoroutine(ctx => CombatLvL12());
                    case 11:
                    case 10:
                        return new ActionRunCoroutine(ctx => CombatLvL10());
                    case 9:
                    case 8:
                        return new ActionRunCoroutine(ctx => CombatLvL8());
                    case 7:
                    case 6:
                        return new ActionRunCoroutine(ctx => CombatLvL6());
                    case 5:
                    case 4:
                        return new ActionRunCoroutine(ctx => CombatLvL4());
                    case 3:
                    case 2:
                        return new ActionRunCoroutine(ctx => CombatLvL2());
                    default:
                        return new ActionRunCoroutine(ctx => CombatLvL1());
                }
            }
        }

        private async Task<bool> OutOfCombat()
        {
            if (Core.Player.InCombat)
                return false;
            else
                return true;
        }

        #endregion

        #region Combat Rotations

        public abstract Task<bool> CombatLvL1();
        public async virtual Task<bool> CombatLvL2()  { return await CombatLvL2(); }
        public async virtual Task<bool> CombatLvL4()  { return await CombatLvL4(); }
        public async virtual Task<bool> CombatLvL6()  { return await CombatLvL6(); }
        public async virtual Task<bool> CombatLvL8()  { return await CombatLvL8(); }
        public async virtual Task<bool> CombatLvL10() { return await CombatLvL10(); }
        public async virtual Task<bool> CombatLvL12() { return await CombatLvL12(); }
        public async virtual Task<bool> CombatLvL14() { return await CombatLvL14(); }
        public async virtual Task<bool> CombatLvL16() { return await CombatLvL16(); }
        public async virtual Task<bool> CombatLvL18() { return await CombatLvL18(); }
        public async virtual Task<bool> CombatLvL20() { return await CombatLvL20(); }
        public async virtual Task<bool> CombatLvL22() { return await CombatLvL22(); }
        public async virtual Task<bool> CombatLvL24() { return await CombatLvL24(); }
        public async virtual Task<bool> CombatLvL26() { return await CombatLvL26(); }
        public async virtual Task<bool> CombatLvL28() { return await CombatLvL28(); }
        public async virtual Task<bool> CombatLvL30() { return await CombatLvL30(); }
        public async virtual Task<bool> CombatLvL32() { return await CombatLvL32(); }
        public async virtual Task<bool> CombatLvL34() { return await CombatLvL34(); }
        public async virtual Task<bool> CombatLvL36() { return await CombatLvL36(); }
        public async virtual Task<bool> CombatLvL38() { return await CombatLvL38(); }
        public async virtual Task<bool> CombatLvL40() { return await CombatLvL40(); }
        public async virtual Task<bool> CombatLvL42() { return await CombatLvL42(); }
        public async virtual Task<bool> CombatLvL44() { return await CombatLvL44(); }
        public async virtual Task<bool> CombatLvL46() { return await CombatLvL46(); }
        public async virtual Task<bool> CombatLvL48() { return await CombatLvL48(); }
        public abstract Task<bool> CombatLvL50();

        public async virtual Task<bool> PVPRotation() { return await CombatLvL50(); }

        #endregion

    }
}
